import java.util.regex.Pattern;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

public class FontNamePatternFilter extends ViewerFilter {
    private String pattern;

    public FontNamePatternFilter() {
        super();

        pattern = ".*";
    }

    public void setPattern(String newPattern) {
        pattern = ".*" + newPattern + ".*";
    }

    @Override
    public boolean select(Viewer viewer, Object parentElement, Object element) {
        return Pattern.matches(
            pattern.toLowerCase(), 
            ((FontItem) element).getFontData().getName().toLowerCase());
    }

}
